import time

import flet

def controls(page: flet.Page):

    i = flet.Image(src="https://picsum.photos/150/150", width=150, height=150)

    def animate(e):
        sw.content = flet.Image(src=f"https://picsum.photos/150/150?{time.time()}", width=150, height=150)
        page.update()

    sw = flet.AnimatedSwitcher(
        i,
        transition=flet.AnimatedSwitcherTransition.SCALE,
        duration=500,
        reverse_duration=500,
        switch_in_curve=flet.AnimationCurve.BOUNCE_OUT,
        switch_out_curve=flet.AnimationCurve.BOUNCE_IN,)
    return[   flet.AppBar(title=flet.Text("Animate")), sw,
        flet.ElevatedButton("Animate!", on_click=animate), ]
def animateView(page):
    return flet.View(
                "/",
                controls(page),
            )
if __name__=="__main__":
    flet.app(target=main)